/*
 * 
 * 
 * 
 */
package com.hboxs.asl.entity;

import com.hboxs.asl.util.DateUtils;
import com.hboxs.asl.util.HtmlUtil;

import javax.persistence.*;

/**
 * Entity - 文章
 */
@Entity
@Table(name = "xx_essay")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "xx_essay_sequence")
public class Essay extends OrderEntity {

    private static final long serialVersionUID = -6109590619123943215L;

    /**
     * 标题
     */
    private String title;

    /**
     * 内容
     */
    private String content;

    /**
     * 用户
     */
    private Member member;

    /**
     * 文章封面
     */
    private String imageURL;

    private Category category;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Lob
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Transient
    public String getContentWithoutTag(){
        return HtmlUtil.getTextFromHtml(this.getContent());
    }

    @Transient
    public String getCreateDateF(){
        return DateUtils.date2Str(super.getCreateDate());
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public Member getMember() {
        return member;
    }

    public void setMember(Member member) {
        this.member = member;
    }

    public String getImageURL() {
        return imageURL;
    }

    public void setImageURL(String imageURL) {
        this.imageURL = imageURL;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }
}